//
//  AuthorizedLogin.m
//  ArtCircle
//
//  Created by sunbin on 2017/5/18.
//  Copyright © 2017年 Quanli. All rights reserved.
//

#import "AuthorizedLogin.h"
#import "ThirdLoginView.h"

@interface AuthorizedLogin()

@property (nonatomic ,strong) UILabel *titleLab;
@property (nonatomic ,assign) CGFloat titleLabWidth;

@property (nonatomic ,strong) UIView *lineView;


@property (nonatomic, weak) ThirdLoginView *thirdView;

@end

@implementation AuthorizedLogin
- (UIView *)lineView{
    
    if (!_lineView) {
        _lineView = [[UIView alloc] init];
        self.lineView.backgroundColor = [UIColor lightGrayColor];
        [self addSubview:_lineView];
    }
    return _lineView;
    
}

-(UILabel *)titleLab {
    
    if (!_titleLab) {
        _titleLab = [[UILabel alloc] init];
        _titleLab.textAlignment = NSTextAlignmentCenter;
        _titleLab.backgroundColor = [UIColor blackColor];
        _titleLab.textColor = [UIColor lightGrayColor];
        _titleLab.text = @"使用以下方式登录";
        
        [self addSubview:_titleLab];
    }
    return _titleLab;
}


- (ThirdLoginView *)thirdView
{
    if (!_thirdView) {
        ThirdLoginView *third = [[ThirdLoginView alloc] initWithFrame:CGRectMake(0, 0, 400, 200)];
        [third setClickLogin:^(LoginType type) {

        }];
        [self addSubview:third];
        _thirdView = third;
    }
    return _thirdView;
}



- (void)layoutSublayersOfLayer:(CALayer *)layer{
    [super layoutSublayersOfLayer:layer];
    
    
    WEAKSELF;
    [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerX.mas_equalTo(weakSelf.mas_centerX);
        make.left.equalTo(weakSelf.mas_left).with.offset(65);
        make.top.equalTo(weakSelf.mas_top).with.offset((45/2-1));
        
        make.height.mas_equalTo(@2);
    }];
    
    
    
    
    _titleLabWidth = [self.titleLab.text widthWithFont:[UIFont systemFontOfSize:15.f] constrainedToHeight:45] + 21*2;
    
    [self.titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerX.mas_equalTo(weakSelf.mas_centerX);
        make.top.equalTo(weakSelf.mas_top).with.offset(0);
        make.size.mas_equalTo(CGSizeMake(weakSelf.titleLabWidth, 45));
        
    }];
    
    [self bringSubviewToFront:self.titleLab];
    
    
    
    [self.thirdView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(@0);
        make.height.equalTo(@60);
        make.top.equalTo(self.titleLab.mas_top).offset(60);
    }];

    
}




@end
